package com.tjb.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBCon {
    private static final String URL = "jdbc:sqlserver://127.0.0.1:1433;database=MessageMS";
    private static final String UserName = "sa";
    private static final String PassWord = "123456";

    public static Connection getConnection() {
        Connection connection = null;
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            connection = DriverManager.getConnection(URL, UserName, PassWord);
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
            throw new RuntimeException("数据库连接异常", e);
        }
        return connection;
    }
}
